package com.ruge.user.controller;

import com.ruge.core.response.Response;
import com.ruge.user.domain.vo.SignInfoDetailVo;
import com.ruge.user.domain.vo.SignInfoVo;
import com.ruge.user.service.SignService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ruge.wu
 * @since 2021/12/20 15:01
 */
@Slf4j
@RestController
@Api(tags = "【用户 签到 接口】", value = "【用户 签到 接口】")
@RequestMapping("sign")
public class UserSignController {
    @Resource
    private SignService signService;

    @GetMapping("doSign")
    @ApiOperation(value = "【签到】  签到")
    public Response sign(@RequestParam(required = false) @ApiParam(value = "用户id") Long aid,
                         @RequestParam(required = false) @ApiParam(value = "签到日期【yyyyMMdd】") String date) {
        return signService.doSign(aid, date);
    }

    @GetMapping("unSign")
    @ApiOperation(value = "【签到】  清除", notes = "模拟取消签到  用来测试数据用")
    public Response unSign(@RequestParam(required = false) @ApiParam(value = "用户id") Long aid,
                           @RequestParam(required = false) @ApiParam(value = "签到日期【yyyyMMdd】") String date) {
        return signService.unSign(aid, date);
    }

    @GetMapping("/getInfo")
    @ApiOperation(value = "【签到】  获取签到信息", notes = "今日是否签到，当月签到次数，连续签到次数")
    public Response<SignInfoVo> getInfo(@RequestParam(required = false) @ApiParam(value = "用户id") Long aid,
                                            @RequestParam(required = false) @ApiParam(value = "签到日期【yyyyMMdd】") String date) {
        return signService.getInfo(aid, date);
    }

    @GetMapping("/getDetail")
    @ApiOperation(value = "【签到】  获取月签到信息", notes = "获取月签到信息")
    public Response<List<SignInfoDetailVo>> getDetail(@RequestParam(required = false) @ApiParam(value = "用户id") Long aid,
                                                      @RequestParam(required = false) @ApiParam(value = "签到日期【yyyyMM】") String date) {
        return signService.getDetail(aid, date);
    }
}
